/**
 * @param {number[]} nums
 * @return {number}
 */
var majorityElement = function (nums) {
  const len = Math.ceil(nums.length / 2)
  const dataObj = new Map()
  const data = nums.find(item => {
    debugger
    dataObj.has(item) ? dataObj.set(item, dataObj.get(item) + 1) : dataObj.set(item, 1)
    if (dataObj.get(item) >= len) {
      return dataObj.get(item)
    }
  })
  return data
}
console.log(majorityElement([3, 2, 3]))
